package com.wf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wf.domain.ZhrjAlarmInfo;
import com.wf.mapper.ZhrjAlarmInfoMapper;
import com.wf.service.ZhrjAlarmInfoService;
import com.wf.vo.AlarmInfoVO;
import com.wf.vo.DayCountVO;
import com.wf.vo.EventTypeCountVO;
import com.wf.vo.deptIdCountVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author mpk16
* @description 针对表【zhrj_alarm_info(事件表)】的数据库操作Service实现
* @createDate 2024-08-22 18:08:24
*/
@Service
public class ZhrjAlarmInfoServiceImpl extends ServiceImpl<ZhrjAlarmInfoMapper, ZhrjAlarmInfo>
    implements ZhrjAlarmInfoService{

    @Autowired
    ZhrjAlarmInfoMapper zhrjAlarmInfoMapper;

    @Override
    public Map<String, Object> getStatistic() {
//        使用sql语句
//        zhrjAlarmInfoMapper.selectObjs(new LambdaQueryWrapper<ZhrjAlarmInfo>()
//                .select(ZhrjAlarmInfo::getEventType)
//                .groupBy("event_type")
//                .fetch(EventTypeCountVO.class);
//    }

        List<EventTypeCountVO> countByEventType = zhrjAlarmInfoMapper.getCountByEventType();
        List<deptIdCountVO> countByDeptId = zhrjAlarmInfoMapper.getCountByDeptId();
        HashMap<String, Object> map = new HashMap<>();
        map.put("eventTypeCounts",countByEventType);
        map.put("deptIdCounts",countByDeptId);
        //  使用Lambda语句

        return map;
    }

    @Override
    public  List<DayCountVO> monthDayCount(String date) {


        List<DayCountVO> dayCountVOS = zhrjAlarmInfoMapper.monthDayCount(date);

        return dayCountVOS;
    }

    @Override
    public List<AlarmInfoVO> multipleTables() {
        List<AlarmInfoVO> alarmInfoVOS = zhrjAlarmInfoMapper.multipleTables();

        return alarmInfoVOS;
    }
}




